package day05;

import java.nio.charset.StandardCharsets;

public class Demo01 {
    public static void main(String[] args) {
        /*
         * UTF-8 编码演示
         */
        //字符串中存储的是Unicode编码
        String str = "Aα产\uD83D\uDE02";
        //转换成UTF-8编码
        byte[] bytes = str.getBytes(StandardCharsets.UTF_8);
        for (byte b : bytes) {
            System.out.println(Integer.toBinaryString(b & 0xff));
        }
        //UTF-8 解码为 Unicode
        String s = new String(bytes, StandardCharsets.UTF_8);
        System.out.println(s);
    }
}
